import java.util.Scanner;


public class RandomEventGenerator 
{
	private MainPlayerModel mm;
	private InventoryModel im;
	
	public RandomEventGenerator(MainPlayerModel mm, InventoryModel im)
	{
		this.mm = mm;
		this.im = im;
	}
	
	
	public String doRandom()
	{
		int eventIndex = (int) (Math.random() * 5 + 1);
		int personIndex = (int) (Math.random() * 4);
		String message = "";
		
		switch(eventIndex)
		{
			case 1:
				message = "You were nice enough to save a hitchhiker from impending death by having him tag along, but" +
						  " he was not nice enough to not steal $50.";
				mm.setTotalCash(mm.getTotalCash() - 50);
				break;
			case 2:
				message = "Desperate villagers have raided your car and stolen 20 lbs of food.";
				im.getItems().get(1).setQuantity(im.getItems().get(1).getQuantity() - 2);
				break;
			case 3:
				message = "A zombie has attacked " + mm.getPartyMembers()[personIndex] 
						   + ". You were forced to shoot the passenger with the ammunition you bought.";
				
			/*	Scanner inStr = new Scanner(mm.getPartyMembersInOneStr());
				String[] newPeople = new String[4]; 
				
				int i = 0;
				for(; i < personIndex; i++)	
					newPeople[i] += inStr.next();
				inStr.next();
				newPeople[i] = "";
				
				++i;
				while(inStr.hasNext())
				{
					newPeople[i] = inStr.next();
					i++;
				}
				inStr.close();
			
				mm.setNumPartyMembers(0);
				mm.setPartyMembers(newPeople);*/
				break;
			case 4:
				message = "Running over a zombie courpse with sharp, protuding bones has popped one " +
						  "of your tires. You apply a spare.";
				im.getItems().get(4).setQuantity(im.getItems().get(4).getQuantity() - 1);
				break;
			case 5:
				message = "Everything is going according to plan.";
				break;
		}
		
		return message;
	}
}
